/*
-----------------------------------------------------------------------------
This file is part of NxGraphics, Multimedia Engine.
Author : Stephane Kyles. Developed in Prague, Czech Republic.
		_   __       ______                     __     _            
	   / | / /_  __ / ____/_____ ____ _ ____   / /_   (_)_____ _____
	  /  |/ /| |/_// / __ / ___// __ `// __ \ / __ \ / // ___// ___/
	 / /|  /_>  < / /_/ // /   / /_/ // /_/ // / / // // /__ (__  ) 
	/_/ |_//_/|_| \____//_/    \__,_// .___//_/ /_//_/ \___//____/  
									/_/                             
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __NXGRAPHICSOVERLAYMANAGER_H__
#define __NXGRAPHICSOVERLAYMANAGER_H__

#include "NxGraphics_Prerequisites.h"

namespace NxGraphics_Namespace {

class NxGraphics_Export NxOverlayManager : public Singleton<NxOverlayManager>
{
public :
	//! NxOverlayManager class constructor
	NxOverlayManager();
	//! NxOverlayManager class destructor
	~NxOverlayManager();
	//! NxOverlayManager Singleton.
	static NxOverlayManager& getSingleton();
	//! NxOverlayManager Singleton.
	static NxOverlayManager* getSingletonPtr();
	//! Create an Overlay.
	NxOverlay * CreateOverlay( const std::string & Name );
	//! Create a container
	NxOverlayContainer * CreateContainer( const std::string & PanelName );
	//! Create a text element
	NxOverlayElementTextArea * CreateTextElement( const std::string & TextElementName );
 

};

template<> NxOverlayManager* Singleton<NxOverlayManager>::ms_Singleton = 0;

enum NxMetricsMode
{
    /// 'left', 'top', 'height' and 'width' are parametrics from 0.0 to 1.0
    GMM_RELATIVE,
    /// Positions & sizes are in absolute pixels
    GMM_PIXELS,
    /// Positions & sizes are in virtual pixels
    GMM_RELATIVE_ASPECT_ADJUSTED
};

class NxGraphics_Export NxOverlayElement
{
public :
	//! NxOverlayElement class constructor
	NxOverlayElement();
	//! NxOverlayElement class destructor
	~NxOverlayElement();
	//! Set metric mode
	virtual void SetMetricsMode( NxMetricsMode Mode );
	//! Set Position.
	void SetPosition( float X, float Y);
	//! Set Dimensions.
	void SetDimensions( float Width , float Height );
	//! Set Material name
	virtual void SetMaterialName( const std::string & matName );
	//! Get Material Name
	virtual const std::string & GetMaterialName() const;
	//! Get Width.
	float GetWidth() const;
	//! Set Width.
	void SetWidth( float Width );
	//! Get Height.
	float GetHeight() const;
	//! Set Height.
	void SetHeight( float Height );
	//! Set left
	void SetLeft( float left);
	//! get Left
	float GetLeft() const;
	//! Show
	void Show();
	//! Hide
	void Hide();
	//! get base element
	Ogre::OverlayElement * GetElement();
protected :
	Ogre::OverlayElement * mOverlayElement;
};


class NxGraphics_Export NxOverlayContainer : public NxOverlayElement
{
public :
	//! NxOverlayContainer class constructor
	NxOverlayContainer( const std::string & PanelName );
	//! NxOverlayContainer class destructor
	~NxOverlayContainer();
	//! Add text Element.
	void AddTextElement( NxOverlayElementTextArea * elem );
	//! add child to container.
	void AddChild( NxOverlayElement * elem );
	//! Remove container child.
	void RemoveChild( const std::string & name );
};

class NxGraphics_Export NxOverlayElementTextArea : public NxOverlayElement
{
public :
	//! NxOverlayContainer class constructor.
	NxOverlayElementTextArea( const std::string & TextElementName );
	//! NxOverlayContainer class destructor.
	~NxOverlayElementTextArea();
	//! set metric mode.
	void setMetricsMode( NxMetricsMode gmm );
	//! Set Parameter Value.
	void SetParameter( const std::string & ParameterName, const std::string & ParameterValue );
	//! Set Text Caption.
	void SetCaption( const std::string & Caption );
	//! Get Caption.
	const std::string & GetCaption() const;
	//! Set Char Height.
	void SetCharHeight( float Size );
	//! Set Text Space Width.
	void SetSpaceWidth( float Width );
	//! Set Font Name.
	void SetFontName( const std::string & FontName );
	//! Set Font Bottom Colour.
	void SetColourBottom( Ogre::ColourValue Val );
	//! Set Font Top Colour.
	void SetColourTop( Ogre::ColourValue Val );
};

class NxGraphics_Export NxOverlay
{
public :
	//! NxOverlay class constructor
	NxOverlay( const std::string & Name );
	//! NxOverlay class destructor
	~NxOverlay();
	//! Show Overlay.
	void Show();
	//! hide Overlay
	void Hide();
	//! Add Container.
	void Add2D( NxOverlayContainer * cont );
	//! remove Container.
	void Remove2D( NxOverlayContainer * cont );
private :
	Ogre::Overlay * mOverlay;
};

class NxLoadingBar;
class NxGraphics_Export ProgressBar 
{
public:
	ProgressBar( const std::string & PanelName, const std::string& caption, float width, float commentBoxWidth);
	void setProgress( float progress);
	float getProgress();
	const std::string & getCaption();
	void setCaption( const std::string& caption);
	const std::string & getComment();
	void setComment(const std::string & comment);
	NxOverlayContainer * GetContainer();

	void Start(  unsigned short NumGroups, unsigned short NumGroupsLoad, float Proportion );

	void Finish();


protected:

	NxOverlayElementTextArea* mTextArea;
	NxOverlayElementTextArea* mCommentTextArea;
	NxOverlayContainer* mMeter;
	NxOverlayElement* mFill;
	NxOverlayContainer * mElement;
	float mProgress;

private :
	NxLoadingBar * mLoadingBar;


};



 
 

}//namespace

#endif